<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.11.0.min.js"></script>

</head>
<body>
<div><form>
    <p>二类账户绑定一类账户</p>
    <input type="hidden" name="id" id="id">
    姓名：<input type="text" id="name" name="name" placeholder="请输入姓名"> <br>
    一类卡卡号：<input type="text" id="id1" name="id1" placeholder="请输入一类卡卡号"> <br>
    手机号：<input type="text" id="phone" name="phone"placeholder="请输入手机号"> <br>
    支付密码：<input type="password" id="password" name="password"placeholder="请输入支付密码"> <br>
</form>

    <input type="button" id="btn" value="绑定"></div>
<table width="100%" id="shouye">
    <tr>
        <td align="center"><a href="/airong/index.html">首页</a></td>
        <!--    <td align="center"><a href="#"><input type="button" id="lc" value="理财"></a></td>-->
        <td align="center"><a href="" id="lc">理财</a></td>
        <td align="center"><a href="/airong/personalCenter.html">我的</a></td>

    </tr>
</table>
</body>
<script>
    let urll = "/airong/cc?action=getSessionID";
    let paramsl = {}
    $.get(urll,paramsl,function (sessionID){
        document.getElementById('lc').href= "products.html?uid="+sessionID;
    },"text")

    let id2 = getUrlParms("id")//获得传过来的二类卡卡号
    $("#btn").click(function (){
        let url = "/airong/card?action=binding"
        let id1 = $("#id1").val();
        let phone = $("#phone").val();
        let password = $("#password").val();
        let name = $("#name").val();
        let params = {id2,id1,phone,password,name}

        $.post(url,params,function (data){
            if (data === "\"true\""){
                alert("绑定成功")
                location.href = "account.html"
            }else if (data === "\"falseNull\""){
                alert("绑定失败,无此银行卡")
            }
        },"text")
    })
    function getUrlParms (name) {
        let url = window.location.href;//获取请求进来的完整url
        let tstr = url.substring(url.indexOf('?') + 1).split('&');//先截取url的?后面的参数部分，在根据&分割成参数数组
        let result = {};
        tstr.forEach((item) => {
            let res = item.split('=');//res为type,my-component1.vue。  res[0]为type，res[1为]my-component1.vue
            result[res[0]] = res[1];//构造成键值对形式 res[0]为键，res[1]为值 例：type: "my-component1.vue"
        });
        return result[name];//通过键取值
    };
</script>
<style>
    div {

        width: 100%;
        text-align: center;
    }
    input{
        padding: 10px;
        margin: 10px;
        text-align: left;
    }
    #shouye{
        position: absolute;
        top: 600px;
        padding: 5px;
        margin: 4px;
        background-color: bisque;
        font-size: 20px;
        text-align: center;
        z-index: 1;
    }
    a {
        display: inline-block;
        position: relative;
        z-index: 1;
        padding: 5px;
        margin: 4px;
        background-color: bisque;
        font-size: 20px;
        text-align: center;
        margin:auto
    }
</style>
</html>